import request from '@/utils/request';
import Qs from 'qs';
import { AxiosPromise } from 'axios';
import { SupplierAddProductsVO, SupplierAddProductsForm, SupplierAddProductsQuery, DataInvite } from '@/api/system/supplierAddProducts/types';

/**
 * 查询供应商添加商品列表
 * @param query
 * @returns {*}
 */

export const listSupplierAddProducts = (query?: SupplierAddProductsQuery): AxiosPromise<SupplierAddProductsVO[]> => {
  return request({
    url: '/electroniccommerce/hmProducts/list',
    method: 'get',
    params: query
    // data: query
  });
};

export const listSupplierAddProduct = (query?: SupplierAddProductsQuery): AxiosPromise<SupplierAddProductsVO[]> => {
  return request({
    url: '/basic/hmProducts/list',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    method: 'post',
    data: Qs.stringify(query)
  });
};

/**
 * 查询供应商添加商品详细
 * @param id
 */
export const getSupplierAddProducts = (id: string | number): AxiosPromise<SupplierAddProductsVO> => {
  return request({
    url: '/basic/hmProducts/' + id,
    method: 'get'
  });
};

/**
 * 查询供应商添加商品详细
 * @param id
 */
export const getInfoInvent = (data: any) => {
  return request({
    url: '/basic/hmProducts/getInfoInvent',
    method: 'post',
    data
  });
};

/**
 *  一键查询 PDD DY 快手 数据信息
 * @param saleLink
 */
export const getSupplierLinkInfo = (saleLink: string | number): AxiosPromise<SupplierAddProductsVO> => {
  return request({
    url: '/system/hmProducts/' + saleLink,
    method: 'get'
  });
};

/**
 * 新增供应商添加商品
 * @param data
 */
export const addSupplierAddProducts = (data: SupplierAddProductsForm) => {
  return request({
    url: '/electroniccommerce/hmProducts',
    method: 'post',
    data: data
  });
};

/**
 * 修改供应商添加商品
 * @param data
 */
export const updateSupplierAddProducts = (data: SupplierAddProductsForm) => {
  return request({
    url: '/electroniccommerce/hmProducts',
    method: 'put',
    data: data
  });
};

/**
 * 删除供应商添加商品
 * @param id
 */
export const delSupplierAddProducts = (id: string | number | Array<string | number>) => {
  return request({
    url: '/electroniccommerce/hmProducts/' + id,
    method: 'delete'
  });
};

/**
 * 商品提报
 * @param id
 */
export const auditSupplierAddProducts = (id: string | number | Array<string | number>) => {
  return request({
    url: '/electroniccommerce/hmProducts/audit/' + id,
    method: 'post'
  });
};

/**
 * 商品提报
 * @param data
 */
export const auditSupplierInvite = (data: DataInvite[]) => {
  return request({
    url: '/electroniccommerce/hmProducts/shipping',
    method: 'post',
    data: data
  });
};

/**
 * 无货反馈
 * @param data
 */
export const hmProductsStock = (data: { id: string; stockRemarks: string }) => {
  return request({
    url: '/electroniccommerce/hmProducts/stock',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    method: 'post',
    data: Qs.stringify(data)
  });
};

/**
 * 通过商品id查询快平台商品实际信息
 * @param query
 * @returns {*}
 */

export const getcommodityinfobykwaiitemid = (query: { kwaiItemId?: string }) => {
  return request({
    url: '/electroniccommerce/kuaishou/getcommodityinfobykwaiitemid',
    method: 'get',
    params: query
  });
};


/**
 * 类目：根据父级代码获取子类
 * @param query
 * @returns {*}
 */

export const getproductscategorychildlistbypid = (query: { pid?: string | number }) => {
  return request({
    url: '/basic/productsCategory/getproductscategorychildlistbypid',
    method: 'get',
    params: query
  });
};


/**
 * 类目：根据子类id返回所有父级
 * @param query
 * @returns {*}
 */

export const getproductscategorypaterlistbycid = (query: { cid?: string | number }) => {
  return request({
    url: '/electroniccommerce/productsCategory/getproductscategorypaterlistbycid',
    method: 'get',
    params: query
  });
};

/**
 * 类目根据id查询pid
 * @param data
 * @returns
 */
export const getListById = (data?: any) => {
  return request({
    url: "/basic/productsCategory/getListById",
    method: "post",
    data: data,
  });
};

/**
 * 商品列表
 * @param data
 * @returns
 */
export const queryProductList = (data?: any) => {
  return request({
    url: "/basic/warehouse/queryProduct",
    method: "post",
    data: data,
  });
};

/**
 * 商品列表-详情
 * @param data
 * @returns
 */
export const scanProductLook = (data?: any) => {
  return request({
    url: "/basic/warehouse/scanProduct",
    method: "post",
    data: data,
  });
};

/**
 * 商品列表-详情
 * @param data
 * @returns
 */
export const grounding = (data?: any) => {
  return request({
    url: "/basic/stock/grounding",
    method: "post",
    data: data,
  });
};

/**
 * 补样邀约-产品部
 * @param data
 * @returns
 */
export const addSampleInvitation = (data?: any) => {
  return request({
    url: "/basic/sampleInvitation/addSampleInvitation",
    method: "post",
    data: data,
  });
};


// 查询商品类目
export const categoryList = (data: any) => {
  return request({
    url: "/basic/category/list",
    method: "post",
    data,
  });
};


// 查询商品类目
export const hmProductsEdit = (data: any) => {
  return request({
    url: "/basic/hmProducts",
    method: "put",
    data,
  });
};

/**
 * 修改商品为待上架
 * @param data
 */
export const editLive = (data: string) => {
  return request({
    url: "/basic/hmProducts/editLive",
    method: "post",
    data: data,
  });
};

// 研发部修改商品
export const editByInvent = (data: any) => {
  return request({
    url: "/basic/hmProducts/editByInvent",
    method: "post",
    data,
  });
};

// 新增商品
export const addHmProducts = (data: any) => {
  return request({
    url: "/basic/hmProducts",
    method: "post",
    data,
  });
};

// 研发新增商品
export const addProduct = (data: any) => {
  return request({
    url: "/basic/hmProducts/addProduct",
    method: "post",
    data,
  });
};

// 修改卖点
export const updateProductSell = (data: any) => {
  return request({
    url: "/basic/quality/updateProductSell",
    method: "post",
    data,
  });
};





